﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.IO;
using System.Linq;
using System.Threading.Tasks;

namespace PhotoGallery.Models
{
    /// <summary>
    /// 照片存储模型
    /// </summary>
    public class PhotoInfoModel
    {
        //public PhotoInfoEntity(string albumName,string name,string path)
        //{
        //    Name = name;//fileInfo.Name;
        //    Path = path;//fileInfo.FullName;
        //    AlbumName = albumName;
        //}
        /// <summary>
        /// 图片SHA1值
        /// </summary>        
        [Key]
        public string Hash { get; set; }

        /// <summary>
        /// 照片名称
        /// </summary>
        [Required]
        public string Name { get; set; }

        /// <summary>
        /// 所属名称
        /// </summary>
        [Required]
        public string AlbumName { get; set; }

        /// <summary>
        /// 图片文件相对路径
        /// </summary>
        [Required]
        public string Path { get; set; }

        /// <summary>
        /// 本地文件路径
        /// </summary>
        public string LocalPath { get; set; }

        /// <summary>
        /// 上传时间
        /// </summary>
        public DateTime UploadDate { get; set; } = DateTime.Now;

        /// <summary>
        /// 上传者
        /// </summary>
        public string UploadUser { get; set; } = "";

        /// <summary>
        /// 上传来源：0:web端，1:Android客户端，2：服务器本地上传
        /// </summary>
        public int UploadClient { get; set; } = 0;


        /// <summary>
        /// CDN加速地址
        /// </summary>
        public string CDNUrl
        {
            get;set;
        } 

        /// <summary>
        /// CDN加速地址2
        /// 腾讯云存储有2个地址，一个为CDN域名加速地址和非CDN服务器地址
        /// </summary>
        public string CDNUrl2
        {
            get;set;            
        }

        /// <summary>
        /// 描述
        /// </summary>
        public string Description { get; set; }
    }


    /// <summary>
    /// 相册存储模型
    /// </summary>
    public class AlbumInfoModel
    {
        
        /// <summary>
        /// 相册ID
        /// </summary>
        [Key]
        public string Id { get; set; }

        /// <summary>
        /// 相册名称
        /// </summary>
        [Display(Name  ="相册名称")]
        public string Name { get; set; }

        /// <summary>
        /// 描述
        /// </summary>
        [Display(Name ="描述")]
        public string Description { get; set; }

        /// <summary>
        /// 相册类型 0：公开相册，1：用户相册
        /// </summary>
        [Display(Name="相册类型")]
        public int AlbumType { get; set; } = 0;

        /// <summary>
        /// 相册本地路径
        /// </summary>
        [Required]
        [Display(Name="本地路径")]
        public string AlbumPath { get; set; }

        /// <summary>
        /// 相册封面
        /// </summary>
        [Display(Name="封面图片")]
        public string CoverPhoto { get; set; }

        /// <summary>
        /// 是否公开
        /// </summary>
        [Display(Name="是否公开")]
        public bool IsPublic { get; set; } = true;

        /// <summary>
        /// 访问密码
        /// </summary>
        [Display(Name="访问密码")]
        public string Password { get; set; } = string.Empty;

        /// <summary>
        /// 创建时间
        /// </summary>
        [Display(Name="创建时间")]
        public DateTime CreateDate { get; set; } = DateTime.Now;

        /// <summary>
        /// 所有者
        /// </summary>
        [Display(Name="所有者")]
        public string Owner { get; set; }

        /// <summary>
        /// 照片
        /// </summary>
        [NotMapped]
        public List<PhotoInfoModel> Photos { get; set; } 
    }

    //enum AlbumType
    //{
    //    Public = 0,
    //    User = 1
    //}
}
